DIR=$( dirname "$(readlink -f  ${BASH_SOURCE[0]})" )
PARENTPATH=$(dirname ${DIR})
ROOTPATH=$(dirname ${PARENTPATH})
source ${ROOTPATH}/tools.sh
sh ${PARENTPATH}/valid_docker_images.sh jellyfin
if [ $? != "2" ]; then
  sudo docker pull jellyfin/jellyfin:latest
fi
if [[ ! -d /opt/soft/docker/jellyfin ]]
then
  sudo mkdir -p /opt/soft/docker/jellyfin/{config,cache} 
fi
docker ps -a | grep jellyfin
if [[ $? -eq 1 ]]
then
  docker run -d --name=jellyfin -p 8096:8096 \
	-p 8920:8920 -p 7359:7359/udp -p 1900:1900/udp \
	-v /opt/soft/docker/jellyfin/config:/config -v /opt/soft/docker/jellyfin/cache:/cache -v /home/zxhtom/fm/media:/media \
	-e TZ=Asia/Shanghai -e PUID=0 -e PGID=0 \
	--device=/dev/dri:/dev/dri \
	--add-host=api.themoviedb.org:13.224.161.90 \
	--add-host=api.themoviedb.org:13.35.8.65 \
	--add-host=api.themoviedb.org:13.35.8.93 \
	--add-host=api.themoviedb.org:13.35.8.6 \
	--add-host=api.themoviedb.org:13.35.8.54 \
	--add-host=image.tmdb.org:138.199.37.230 \
	--add-host=image.tmdb.org:108.138.246.49 \
	--add-host=api.thetvdb.org:13.225.89.239 \
	--add-host=api.thetvdb.org:192.241.234.54 \
	--restart unless-stopped \
	jellyfin/jellyfin:latest
else
  docker restart jellyfin
fi

docker exec -it jellyfin apt update
docker exec -it jellyfin apt fonts-noto-extra
docker exec -it jellyfin apt intel-media-va-driver
docker exec -it jellyfin /usr/lib/jellyfin-ffmpeg/vainfo
#https://zhuanlan.zhihu.com/p/624670198
#file name https://www.chilisdy.site/post/jellyfin/jellyfin-use/
